﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate;
using Microsoft.Practices.Unity;

namespace IISDeploy.Data.Interceptor
{
    public class UnityInterceptor : EmptyInterceptor
    {
        private readonly IUnityContainer container;

        public UnityInterceptor(IUnityContainer container)
        {
            if (container == null)
                throw new Exception("Container is not null.");
            this.container = container;
        }


        public override object Instantiate(string clazz, EntityMode entityMode, object id)
        {
            if (NHibernate.Cfg.Environment.UseReflectionOptimizer)
                return null;
            else
                return base.Instantiate(clazz, entityMode, id);
        }
    }
}
